<script setup>
import { reactive } from 'vue';
import http from '../utils/request.js'
const form = reactive({
  username: '',
  password: ''
});
function login() {
  http.post('/login', form)
    .then((res) => {
      // 修复条件判断，根据实际响应格式调整
      if (res && res.code === 200) {
        console.log('登录成功');
        console.log('响应数据:', res); // 添加这行可以查看完整响应
      } else {
        console.log('登录失败');
        console.log('响应:', res); // 查看失败响应
      }
    })
    .catch((err) => {
      console.log('请求错误:', err);
    })
}
</script>

<style scoped></style>

<template>
<div>
    登录接口测试
    <input v-model="form.username" placeholder="请输入用户名"></input>
    <input v-model="form.password" placeholder="请输入密码"></input>
    <button @click="login">点击登录</button>
</div>
</template>